package it.polimi.travelDreamEJB.basicproductmanagement;

import it.polimi.travelDreamEJB.basicproductmanagement.dto.ExcursionDTO;
import it.polimi.travelDreamEJB.travelpacketmanagement.DefaultPacket;
import it.polimi.travelDreamEJB.travelpacketmanagement.PersonalizedPacket;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.*;


/**
 * The persistent class for the excursion database table.
 * 
 */
@Entity
@Table(name="excursion")
@NamedQueries({
	@NamedQuery(name="Excursion.findAll", query="SELECT e FROM Excursion e"),
	@NamedQuery(name="Excursion.find", query= "SELECT e FROM Excursion e WHERE e.destination LIKE :destination AND e.name LIKE :name AND e.info LIKE :info AND e.price <= :maxPrice AND e.price >= :minPrice  ")
})
public class Excursion implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name="id_excursion")
	private int idExcursion;

	private String destination;

	private String info;

	private String name;

	private int price;
	
	
	@ManyToMany(mappedBy="excursions", cascade=CascadeType.ALL)
	private List<DefaultPacket> default_packets;

	@ManyToMany(mappedBy="excursions", cascade=CascadeType.ALL)
	@JoinColumn(name="id_excursion")
	private List<PersonalizedPacket> personalizedPackets;
	
	public Excursion() {
	}
	
	public Excursion(ExcursionDTO excursion){
		this.default_packets=new ArrayList<DefaultPacket>();
		this.personalizedPackets=new ArrayList<PersonalizedPacket>();
		this.idExcursion=excursion.getId();
		this.destination=excursion.getDestination();
		this.info=excursion.getInfo();
		this.name=excursion.getName();
		this.price=excursion.getPrice();
	}

	public int getIdExcursion() {
		return this.idExcursion;
	}

	public void setIdExcursion(int idExcursion) {
		this.idExcursion = idExcursion;
	}

	public String getDestination() {
		return this.destination;
	}

	public void setDestination(String destination) {
		this.destination = destination;
	}

	public String getInfo() {
		return this.info;
	}

	public void setInfo(String info) {
		this.info = info;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getPrice() {
		return this.price;
	}

	public void setPrice(int price) {
		this.price = price;
	}

	public void setDefault_packets(List<DefaultPacket> default_packets) {
		this.default_packets = default_packets;
	}
	
	public List<DefaultPacket> getDefault_packets() {
		return default_packets;
	}

	public List<PersonalizedPacket> getPersonalizedPackets() {
		return personalizedPackets;
	}

	public void setPersonalizedPackets(List<PersonalizedPacket> personalizedPackets) {
		this.personalizedPackets = personalizedPackets;
	}
	
	
}